//
//  DATUnit.m
//  MapEdit
//
//  Created by Steven Canfield on 28/06/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "DATUnit.h"


#define NUM_UNITS 228

@implementation DATUnit
- (id)initWithData:(NSData *)data {
	self = [super init];
	if( self ) {
		units = malloc( sizeof( units ) * NUM_UNITS );
		
		int unitIndex;
		int dataIndex = 0;
		for( unitIndex = 0; unitIndex < NUM_UNITS; unitIndex++ ) {
			/* Read Unit Info */
			u_int8_t byte;
			[data getBytes:&byte range:NSMakeRange( dataIndex, sizeof( u_int8_t ))];
			dataIndex += sizeof( u_int8_t );
			units[ unitIndex ].flingy_index = byte;
		}
	}
	return self;
}

- (dat_unit_t *)unitAtIndex:(int)index {
//	NSLog(@"%@ => %i", NSStringFromSelector(_cmd), index );
	return &(units[ index ]);
}
@end
